package controllers;

import java.util.List;

import play.mvc.*;
import models.forumCategory;
import models.forumPost;
import models.forumSubject;
import play.data.validation.Valid;

public class Forum extends Controller {

    public static void index() {
        List<forumCategory> entities = models.forumCategory.all().fetch();
        render(entities);
    }

    public static void showcategory(Long id) {
        List<forumSubject> entities = models.forumSubject.find("select Sub from forumSubject Sub where forumCategory_id=?", id).fetch();
        render(entities);
    }
    public static void showpost(Long id) {
        //forumCategory entities_Category = forumCategory.findById(id);
        forumSubject entity_Sub = forumSubject.findById(id);
        List<forumPost> entities_Post =  models.forumSubject.find("select Post from forumPost Post where forumSubject_id=?", id).fetch();
        render(entity_Sub, entities_Post);
    }
    
    public static void post(boolean isSubject, forumSubject post)
    {
        render(isSubject, post);
        
        
        
    }
    public static void savePost(boolean isSubject, @Valid forumSubject post)
    {
        
        
        
    }
}
